/*******************************************************************************************
Copyright (C) 2008 Mestrelab Research S.L. All rights reserved.

This file is part of the MNova scripting toolkit.

Authorized users of MNova Software may use this file freely, but this file is provided AS IS
with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE.
*******************************************************************************************/ 

function textStreamTest()
{
	var f = new File(Dir.temp()+"/MNova_TextStream_Test.txt");
	f.open(File.WriteOnly); 
	print(f);

	var s = new TextStream(f);
	print(s);

	s1 = s;
	print(s1);
	
	var s2 = new TextStream(s);
	print(s2);

	var pi = 3.14159265358979;

	s.write("Hello World! ", 100, ",  \t", pi, "\n");
	s.write("Second line\n");
	s.writeln("Third line");
	s.precision = 10;
	s.write(pi, '\n');
	s.notation = TextStream.nScientific;
	s.write(pi, "\n");
	s.notation = TextStream.nFixed;
	s.write(pi, "\n");
	s.notation = TextStream.nSmart;
	s.write(pi, "\n");
	s.write("Last line");
	print(s);
	print(f);
	s.flush();
	print(f);

	f.close(); // important to call close() before opening in another mode
	print(f);
	f.open(File.ReadOnly);
	print(s);
	print(s.readLine());
	print(s.readLine());
	print(s.readLine());
	print(s.readLine());

	s.pos = 6;
	print(s);
	print(s.readLine());
	print(s.readLine());
	print(s.readLine());

	s.pos = 0;
	print(s.read(6));
	print(s.readAll());

	s.pos = 0;
	print(s.readString());
	print(s.readString());
	print(s.readNumber());
	print(s.readString());
	print(s.readLine());
	print(s.readLine());
	print(s.readLine());
	print(s.readNumber());

	f.close();
	f.remove();
	print(f);
}
